package com.orphan.audit.dao;

import com.orphan.audit.po.Deposit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author wdn
 * @since 2021-07-15
 */

@Repository
@Mapper
public interface DepositMapper extends BaseMapper<Deposit> {

    @Select("select * from t_deposit")
    List<Deposit> findAll();


    @Select("select count(0) from t_deposit where t_userId=#{tUserid}")
    Integer exist(@Param("tUserid")Long id);


    @Select("select * from t_deposit where t_userId=#{tUserid}")
    Deposit queryDeposit(@Param("tUserid")long id);

    @Update("update t_deposit set t_total=#{deposit.tTotal},t_balance=#{deposit.tBalance} where " +
            "t_userId=#{deposit.tUserid}")
    Integer update(@Param("deposit")Deposit deposit);

    @Update("update t_deposit set t_balance=#{deposit.tBalance} where t_userId=#{deposit.tUserid}")
    Integer reduce(Deposit deposit);
}
